package lab02.test21;

import java.util.Scanner;

public class Test21 {
    //统计一个字符串中给定字符出现的频率
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入字符串：");
        String str=sc.nextLine();
        char [] arr=str.toCharArray();
        int count=0;
        for (int i=0;i<arr.length;i++){
            if (arr[i]=='a'){
                count++;
            }
        }
        System.out.println("字符a出现的频率是："+count);
    }
}
